﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Text;
using Chenxin.Lib.Utility;
using Chenxin.Lib.Passport.Entity;
using System.Collections.Generic;

public partial class ShowDetailInfoWithRegion : PageBase
{
    Chenxin.Lib.Cache.CacheService cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.GLOBAL);

    protected void Page_Load(object sender, EventArgs e)
    {

        try
        {
            //房屋ID
            string strHouseId = Context.Request.Params["houseid"];

            if (string.IsNullOrEmpty(strHouseId))
            {
                Context.Response.Redirect(string.Format("/errorpage.aspx?msg={0}", "房源ID不存在"));
            }

            //取得房源基本信息

            Chenxin.Lib.House.Entity.House_BaseInfo entHouseBaseInfo = null;
            //string strCachKey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_HOUSEINFO, strHouseId);
            
            //entHouseBaseInfo = cs.GetObject<Chenxin.Lib.House.Entity.House_BaseInfo>(strCachKey);
            //if (!cs.Hit)
            //{
                entHouseBaseInfo = Chenxin.Lib.House.BLL.House_BaseInfo.GetHouseInfoEntity(strHouseId);
            //    if (entHouseBaseInfo != null) cs.Set(strCachKey, entHouseBaseInfo, DateTime.Now.AddHours(1));
            //}

            /************************************************************************************************************************/
            if (entHouseBaseInfo.Status == 30)
            {
                System.Text.StringBuilder sb1 = new System.Text.StringBuilder();
                //查看所有封盘
                if (CurrentUserInfo.ContainsPermit(Constants.Permit_ViewAllLockedHouse))
                {
                    sb1.Append(" (1=1) ");
                }
                //查看城市封盘
                else if (CurrentUserInfo.ContainsPermit(Constants.Permit_ViewCityLockedHouse))
                {
                    sb1.Append("EXISTS(");
                    sb1.Append("Select 1 from v_Hr_User_BaseInfo M ");
                    sb1.AppendFormat("WHERE (AskerId = M.Userid OR OperatorId = M.Userid) AND  M.CityId= '{0}' ", CurrentUserInfo.CityId);
                    sb1.Append(")");
                }
                //查看公司封盘
                else if (CurrentUserInfo.ContainsPermit(Constants.Permit_ViewCompanyLockedHouse))
                {
                    sb1.Append("EXISTS(");
                    sb1.Append("Select 1 from v_Hr_User_BaseInfo M ");
                    sb1.AppendFormat("WHERE (AskerId = M.Userid OR OperatorId = M.Userid) AND  M.CompanyId= '{0}' ", CurrentUserInfo.CompanyId);
                    sb1.Append(")");
                }
                //部门封盘
                else if (CurrentUserInfo.ContainsPermit(Constants.Permit_ViewDepartLockedHouse))
                {
                    sb1.AppendFormat("(DepartId in (select departid from v_Struct_UserDepartRelation where Userid= '{0}' AND ViewLockHouse =1) or ", CurrentUserInfo.UserId);
                    sb1.AppendFormat("AskerDepartId in (select departid from v_Struct_UserDepartRelation where Userid= '{0}' AND ViewLockHouse =1)) ", CurrentUserInfo.UserId);
                    //sb1.Append("EXISTS(");
                    //sb1.Append("Select 1 from v_Struct_UserDepartRelation M ");
                    //sb1.AppendFormat("WHERE (AskerDepartId = M.Departid OR DepartId = M.Departid) AND  M.Userid= '{0}' AND M.ViewLockHouse =1 ", CurrentUserInfo.UserId);
                    //sb1.Append(")");
                }
                else
                {
                    sb1.AppendFormat(" (AskerId='{0}' OR OperatorId ='{0}' )", CurrentUserInfo.UserId);
                }

                sb1.AppendFormat(" and HouseId = '{0}' and LockedStatus=1 order by InputTime ", entHouseBaseInfo.HouseId);

                List<Chenxin.Lib.House.Entity.House_LockedInfo> list = Chenxin.Lib.House.DAL.House_LockedInfo.GetListArray(sb1.ToString());
                if (list == null || list.Count == 0)
                {
                    Context.Response.Redirect(string.Format("/errorpage.aspx?msg={0}", "该房源已封盘，无查看权限!"), false);
                    return;
                }
            }
            /************************************************************************************************************************/
            
            //没有相应ID的信息
            if (Guid.Empty.Equals(entHouseBaseInfo.HouseId))
            {
                Context.Response.Redirect(string.Format("/errorpage.aspx?msg={0}", "房源信息不存在"));
            }

            if (entHouseBaseInfo.HitNum != null)
                entHouseBaseInfo.HitNum = entHouseBaseInfo.HitNum + 1;
            else
                entHouseBaseInfo.HitNum = 1;
            Chenxin.Lib.House.DAL.House_BaseInfo.Update(entHouseBaseInfo);
            //cs.Delete(strCachKey);

            Chenxin.Lib.House.Entity.House_BusinessSetting hbs = Chenxin.Lib.House.DAL.House_BusinessSetting.GetModel(CurrentUserInfo.CompanyId);
            //0：无规则，10：不显示，20：模糊信息，不查业主，30：详细信息，不能查业主
            if (hbs != null && hbs.UseBlockRole)
            {
                //20：模糊信息
                if (hbs.BlockRoleNum == 20 || hbs.BlockRoleNum == 40)
                {
                    System.Collections.Generic.List<Chenxin.Lib.House.Entity.BlockSetting> list = Chenxin.Lib.House.DAL.BlockSetting.GetListArray(string.Format(" DepartId = '{0}'", CurrentUserInfo.DepartId));
                    Chenxin.Lib.House.Entity.BlockSetting bls = list.Find(delegate(Chenxin.Lib.House.Entity.BlockSetting p) { return p.Block.Equals(entHouseBaseInfo.Region); });
                    //区域外房源
                    if (bls == null && !CurrentUserInfo.UserId.ToString().Equals(entHouseBaseInfo.OprPersonId.ToString()) && !(CurrentUserInfo.ContainsPermit(Chenxin.Lib.Utility.Constants.Permit_Search_DepartmentAll) && (CurrentUserInfo.DepartId.ToString().Equals(entHouseBaseInfo.OprDepartId.ToString()))))
                    {
                        entHouseBaseInfo.Room = "";
                        entHouseBaseInfo.BuildingName = "";
                    }
                }
            }

            //隐藏房屋Id的设定
            hidHouseId.Value = strHouseId;

            //标题设定
            setTitle(entHouseBaseInfo);

            //经纪人信息设定
            setBrokerInfo(entHouseBaseInfo.OprPersonId);

            //房源详情设定
            setHouseDetailInfo(entHouseBaseInfo);

            //看过房源业主的人的信息
            setViewOwnerInfo(strHouseId);

            //房源配置
            if (!string.IsNullOrEmpty(entHouseBaseInfo.BaseEquip))
            {
                lbBaseEquip.Text = entHouseBaseInfo.BaseEquip.Replace("\\n", "<br>");
            }
            //备注
            if (!string.IsNullOrEmpty(entHouseBaseInfo.Remarks))
            {
                lbRemarks.Text = entHouseBaseInfo.Remarks.Replace("\\n", "<br>");
            }

            //隐藏房源信息
            setHidHouseInfo(entHouseBaseInfo);
            setHousePic(strHouseId);
        }
        catch (Exception ex)
        {
            Response.Redirect("/errorpage.aspx?msg=" + ex.Message);
        }
    }

    private void setTitle(Chenxin.Lib.House.Entity.House_BaseInfo entHouseBaseInfo)
    {
        //状态
        StringBuilder strStatue = new StringBuilder();
        //标题
        StringBuilder strTitle = new StringBuilder();
        //房源状态：10=有效；-1=无效；20=暂缓；30=封盘
        strStatue.Append("【");
        if (entHouseBaseInfo.Status == 10)
        {
            strStatue.Append("有效");
        }
        else if (entHouseBaseInfo.Status == -1)
        {
            strStatue.Append("无效");
        }
        else if (entHouseBaseInfo.Status == 20)
        {
            strStatue.Append("暂缓");
        }
        else if (entHouseBaseInfo.Status == 30)
        {
            strStatue.Append("封盘");
        }
        else if (entHouseBaseInfo.Status == -10)
        {
            strStatue.Append("删除");
        } 
        strStatue.Append("】");

        strTitle.Append(entHouseBaseInfo.Community);
        strTitle.Append(entHouseBaseInfo.BuildingName);
        strTitle.Append(entHouseBaseInfo.Room);
        strTitle.Append(",");
        strTitle.Append(entHouseBaseInfo.Model_Room);
        strTitle.Append("室");
        strTitle.Append(entHouseBaseInfo.Model_Hall);
        strTitle.Append("厅");
        strTitle.Append(entHouseBaseInfo.Model_Toilet);
        strTitle.Append("卫");
        strTitle.Append(entHouseBaseInfo.Model_Balcony);
        strTitle.Append("阳台, ");

        if (entHouseBaseInfo.BusinessKind == 10)
        {
            strTitle.Append("售价:");
            if (entHouseBaseInfo.SalePrice_T == 0 || entHouseBaseInfo.SalePrice_T == null)
            {
                strTitle.Append("--");
            }
            else
            {
                strTitle.Append(Convert.ToString(Math.Round((decimal)entHouseBaseInfo.SalePrice_T / 10000, 2)) + "万");
            }
        }
        else if (entHouseBaseInfo.BusinessKind == 20)
        {
            strTitle.Append("租价:");
            if (entHouseBaseInfo.RentPrice == 0 || entHouseBaseInfo.RentPrice == null)
            {
                strTitle.Append("--");
            }
            else
            {
                strTitle.Append(Convert.ToString(Math.Round((decimal)entHouseBaseInfo.RentPrice, 2)) + "(元/月)");
            }
        }
        else if (entHouseBaseInfo.BusinessKind == 30)
        {
            strTitle.Append("售价:");
            if (entHouseBaseInfo.SalePrice_T == 0 || entHouseBaseInfo.SalePrice_T == null)
            {
                strTitle.Append("--");
            }
            else
            {
                strTitle.Append(Convert.ToString(Math.Round((decimal)entHouseBaseInfo.SalePrice_T / 10000, 2)) + "万");
            }
            strTitle.Append("租价:");
            if (entHouseBaseInfo.RentPrice == 0 || entHouseBaseInfo.RentPrice == null)
            {
                strTitle.Append("--");
            }
            else
            {
                strTitle.Append(Convert.ToString(Math.Round((decimal)entHouseBaseInfo.RentPrice, 2)) + "(元/月)");
            }
        }

        //状态
        lbStatue.Text = strStatue.ToString();
        //标题
        lbTitle.Text = strTitle.ToString();

    }

    private void setBrokerInfo(Guid BrokerId)
    {
        //取得经纪人相关信息

        string strKeyUser = string.Format(Chenxin.Lib.Cache.CacheDataType.USER, BrokerId);

        Chenxin.Lib.Passport.Entity.Hr_UserInfo entUserInfo;

        entUserInfo = cs.GetObject<Chenxin.Lib.Passport.Entity.Hr_UserInfo>(strKeyUser);

        if (!cs.Hit)
        {
            entUserInfo = Chenxin.Lib.Passport.DAL.Hr_UserInfo.GetEntityById(BrokerId);
            if (entUserInfo != null) cs.Set(strKeyUser, entUserInfo);
        }

        if (Guid.Empty.Equals(entUserInfo.UserId))
        {
            //经纪人头像
            imgHead.ImageUrl = "/images/jw.jpg";
        }
        else
        {
            //经纪人头像
            if (string.IsNullOrEmpty(entUserInfo.PicUrl))
            {
                imgHead.ImageUrl = "/images/jw.jpg";
            }
            else
            {
                imgHead.ImageUrl = "UploadFile/"+entUserInfo.PicUrl; 
            }
            //经纪人名
            lbBroker.Text = entUserInfo.UserName;
            //经纪人所属部门
            lbBrokerDepartNm.Text = entUserInfo.DepartName;
            //经纪人手机号
            lbBrokerMobile.Text = entUserInfo.Mobile;
        }
    }

    private void setHouseDetailInfo(Chenxin.Lib.House.Entity.House_BaseInfo entHouseBaseInfo)
    {
        //取得门店信息
        Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo hr_depinfo = null;

        string strCachKey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_DEPARTMENT, entHouseBaseInfo.OprDepartId);

        hr_depinfo = cs.GetObject<Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo>(strCachKey);
        if (!cs.Hit)
        {
            Chenxin.Lib.Hr.BLL.Hr_DepartmentInfo bllDepartInfo = new Chenxin.Lib.Hr.BLL.Hr_DepartmentInfo();
            hr_depinfo = bllDepartInfo.GetModel(entHouseBaseInfo.OprDepartId);
            if (hr_depinfo != null) cs.Set(strCachKey, hr_depinfo);
        }


        StringBuilder strHouseInfo = new StringBuilder();
        strHouseInfo.Append("<ul>");
        strHouseInfo.Append("<li class=\"wid1 fl\">房源所在： " + entHouseBaseInfo.Community + entHouseBaseInfo.BuildingName + entHouseBaseInfo.Room + " </li>");
        strHouseInfo.Append("<li class=\"wid2 fl\">房源编号： " + entHouseBaseInfo.HouseCode + " </li>");
        strHouseInfo.Append("<li class=\"wid1 fl\">小区地址： " + entHouseBaseInfo.Address + " </li>");
        strHouseInfo.Append("<li class=\"wid2 fl\">交易： ");
        if (entHouseBaseInfo.BusinessKind == 20)
        {
            strHouseInfo.Append("出租");
            showstate.ImageUrl = "/images/show_rent.gif";
        }
        else if (entHouseBaseInfo.BusinessKind == 10)
        {
            strHouseInfo.Append("出售");
            showstate.ImageUrl = "/images/show_state.gif";
        }
        else
        {
            strHouseInfo.Append("租售");
            showstate.ImageUrl = "/images/sall_state.gif";
        }
        strHouseInfo.Append("</li>");
        strHouseInfo.Append("<li class=\"wid1 fl\">区域： " + entHouseBaseInfo.Region + "</li>");
        strHouseInfo.Append("<li class=\"wid2 fl\">板块：" + entHouseBaseInfo.Block + "</li>");

        strHouseInfo.Append("<li class=\"wid1 fl\">用途： ");
        if (string.IsNullOrEmpty(entHouseBaseInfo.HouseUse))
        {
            strHouseInfo.Append("--");
        }
        else
        {
            strHouseInfo.Append(entHouseBaseInfo.HouseUse);
        }
        strHouseInfo.Append("</li>");

        strHouseInfo.Append("<li class=\"wid2 fl\">类型： ");
        if (string.IsNullOrEmpty(entHouseBaseInfo.BuildingType))
        {
            strHouseInfo.Append("--");
        }
        else
        {
            strHouseInfo.Append(entHouseBaseInfo.BuildingType);
        }
        strHouseInfo.Append("</li>");

        strHouseInfo.Append("<li class=\"wid1 fl\">竣工年份： ");
        if (entHouseBaseInfo.CompleteYear == null || entHouseBaseInfo.CompleteYear == 0)
        {
            strHouseInfo.Append("--");
        }
        else
        {
            strHouseInfo.Append(Convert.ToString(entHouseBaseInfo.CompleteYear) + "年");
        }
        strHouseInfo.Append("</li>");

        if (entHouseBaseInfo.BusinessKind == 10 || entHouseBaseInfo.BusinessKind == 30)
        {
            strHouseInfo.Append("<li class=\"wid2 fl\">售总价： ");
            if (entHouseBaseInfo.SalePrice_T == 0 || entHouseBaseInfo.SalePrice_T == null)
            {
                strHouseInfo.Append("--");
            }
            else
            {
                strHouseInfo.Append(Convert.ToString(Math.Round((decimal)entHouseBaseInfo.SalePrice_T / 10000, 2)) + "万");
            }
            strHouseInfo.Append("</li>");

            strHouseInfo.Append("<li class=\"wid1 fl\">售单价： ");
            if (entHouseBaseInfo.SalePrice_U == 0 || entHouseBaseInfo.SalePrice_U == null)
            {
                strHouseInfo.Append("--");
            }
            else
            {
                strHouseInfo.Append(Convert.ToString(entHouseBaseInfo.SalePrice_U) + "元/㎡");
            }
            strHouseInfo.Append("</li>");

            strHouseInfo.Append("<li class=\"wid2 fl\">售底价： ");
            if (entHouseBaseInfo.SalePrice_R == 0 || entHouseBaseInfo.SalePrice_R == null)
            {
                strHouseInfo.Append("--");
            }
            else
            {
                strHouseInfo.Append(Convert.ToString(Math.Round((decimal)entHouseBaseInfo.SalePrice_R / 10000, 2)) + "万");
            }
            strHouseInfo.Append("</li>");
        }

        if (entHouseBaseInfo.BusinessKind == 20 || entHouseBaseInfo.BusinessKind == 30)
        {
            strHouseInfo.Append("<li class=\"wid1 fl\">租总价： ");
            if (entHouseBaseInfo.RentPrice == 0 || entHouseBaseInfo.RentPrice == null)
            {
                strHouseInfo.Append("--");
            }
            else
            {
                strHouseInfo.Append(Convert.ToString(entHouseBaseInfo.RentPrice) + "元/月");
            }
            strHouseInfo.Append("</li>");

            strHouseInfo.Append("<li class=\"wid2 fl\">租底价： ");
            if (entHouseBaseInfo.RentPrice_R == 0 || entHouseBaseInfo.RentPrice_R == null)
            {
                strHouseInfo.Append("--");
            }
            else
            {
                strHouseInfo.Append(Convert.ToString(entHouseBaseInfo.RentPrice_R) + "元/月");
            }
            strHouseInfo.Append("</li>");

            strHouseInfo.Append("<li class=\"wid2 fl\">合租/支付：");
            if (entHouseBaseInfo.IsGroup)
            {
                strHouseInfo.Append("是");
            }
            else
            {
                strHouseInfo.Append("否");
                if (string.IsNullOrEmpty(entHouseBaseInfo.PayMode))
                {
                    strHouseInfo.Append("--");
                }
                else
                {
                    strHouseInfo.Append(entHouseBaseInfo.PayMode);
                }
            }
            strHouseInfo.Append("</li>");
        }

        strHouseInfo.Append("<li class=\"wid2a fl\">面积： ");
        if (entHouseBaseInfo.BuildingArea == null || entHouseBaseInfo.BuildingArea == 0)
        {
            strHouseInfo.Append("--");
        }
        else
        {
            strHouseInfo.Append(Convert.ToString(entHouseBaseInfo.BuildingArea) + "㎡");
        }
        strHouseInfo.Append("</li>");


        strHouseInfo.Append("<li class=\"wid2b fl\">房型： ");
        if (entHouseBaseInfo.Model_Room == null || entHouseBaseInfo.Model_Room == 0)
        {
            strHouseInfo.Append("--");
        }
        else
        {
            strHouseInfo.Append(Convert.ToString(entHouseBaseInfo.Model_Room) + "室");
        }
        if (entHouseBaseInfo.Model_Hall == null || entHouseBaseInfo.Model_Hall == 0)
        {
            strHouseInfo.Append("--");
        }
        else
        {
            strHouseInfo.Append(Convert.ToString(entHouseBaseInfo.Model_Hall) + "厅");
        }
        if (entHouseBaseInfo.Model_Toilet == null || entHouseBaseInfo.Model_Toilet == 0)
        {
            strHouseInfo.Append("--");
        }
        else
        {
            strHouseInfo.Append(Convert.ToString(entHouseBaseInfo.Model_Toilet) + "卫");
        }
        if (entHouseBaseInfo.Model_Balcony == null || entHouseBaseInfo.Model_Balcony == 0)
        {
            strHouseInfo.Append("--");
        }
        else
        {
            strHouseInfo.Append(Convert.ToString(entHouseBaseInfo.Model_Balcony) + "阳台");
        }
        strHouseInfo.Append("</li>");

        strHouseInfo.Append("<li class=\"wid2a fl\">朝向： ");
        if (string.IsNullOrEmpty(entHouseBaseInfo.Direction))
        {
            strHouseInfo.Append("--");
        }
        else
        {
            strHouseInfo.Append(entHouseBaseInfo.Direction);
        }
        strHouseInfo.Append("</li>");

        strHouseInfo.Append("<li class=\"wid2a fl\">层高： ");
        if (entHouseBaseInfo.Cur_Floor == null || entHouseBaseInfo.Cur_Floor == 0)
        {
            strHouseInfo.Append("--");
        }
        else
        {
            strHouseInfo.Append(Convert.ToString(entHouseBaseInfo.Cur_Floor));
        }
        strHouseInfo.Append("/");
        if (entHouseBaseInfo.Total_Floor == null || entHouseBaseInfo.Total_Floor == 0)
        {
            strHouseInfo.Append("--");
        }
        else
        {
            strHouseInfo.Append(Convert.ToString(entHouseBaseInfo.Total_Floor));
        }
        strHouseInfo.Append("</li>");

        strHouseInfo.Append("<li class=\"wid2b fl\">现状： ");
        if (string.IsNullOrEmpty(entHouseBaseInfo.Actuality))
        {
            strHouseInfo.Append("--");
        }
        else
        {
            strHouseInfo.Append(entHouseBaseInfo.Actuality);
        }
        strHouseInfo.Append("</li>");

        strHouseInfo.Append("<li class=\"wid2a fl\">装修情况： ");
        if (string.IsNullOrEmpty(entHouseBaseInfo.Fitment))
        {
            strHouseInfo.Append("--");
        }
        else
        {
            strHouseInfo.Append(entHouseBaseInfo.Fitment);
        }
        strHouseInfo.Append("</li>");

        strHouseInfo.Append("<li class=\"wid2a fl\">租约： ");
        if (entHouseBaseInfo.HavRentContract)
        {
            strHouseInfo.Append("有");
        }
        else
        {
            strHouseInfo.Append("无");
        }
        strHouseInfo.Append("</li>");

        strHouseInfo.Append("<li class=\"wid2b fl\">产权： ");
        if (string.IsNullOrEmpty(entHouseBaseInfo.Property))
        {
            strHouseInfo.Append("--");
        }
        else
        {
            strHouseInfo.Append(entHouseBaseInfo.Property);
        }
        strHouseInfo.Append("</li>");

        strHouseInfo.Append("<li class=\"wid2a fl\">来源： ");
        if (string.IsNullOrEmpty(entHouseBaseInfo.InfoSource))
        {
            strHouseInfo.Append("--");
        }
        else
        {
            strHouseInfo.Append(entHouseBaseInfo.InfoSource);
        }
        strHouseInfo.Append("</li>");

        strHouseInfo.Append("<li class=\"wid2a fl\">钥匙： ");
        if (entHouseBaseInfo.IsHavekey)
        {
            strHouseInfo.Append("有");
        }
        else
        {
            strHouseInfo.Append("无");
        }
        strHouseInfo.Append("</li>");

        strHouseInfo.Append("<li class=\"wid2b fl\">委托： ");
        if (entHouseBaseInfo.IsTrust)
        {
            strHouseInfo.Append("有");
        }
        else
        {
            strHouseInfo.Append("无");
        }
        strHouseInfo.Append("</li>");

        strHouseInfo.Append("<li class=\"wid2a fl\">备案编号： ");
        if (string.IsNullOrEmpty(entHouseBaseInfo.MarkCode))
        {
            strHouseInfo.Append("--");
        }
        else
        {
            strHouseInfo.Append(entHouseBaseInfo.MarkCode);
        }
        strHouseInfo.Append("</li>");

        strHouseInfo.Append("<li class=\"wid2a fl\">查/跟： ");
        if (entHouseBaseInfo.HitNum == null || entHouseBaseInfo.HitNum == 0)
        {
            strHouseInfo.Append("--");
        }
        else
        {
            strHouseInfo.Append(Convert.ToString(entHouseBaseInfo.HitNum));
        }
        strHouseInfo.Append("/");
        if (entHouseBaseInfo.TraceNum == null || entHouseBaseInfo.TraceNum == 0)
        {
            strHouseInfo.Append("--");
        }
        else
        {
            strHouseInfo.Append(Convert.ToString(entHouseBaseInfo.TraceNum));
        }
        strHouseInfo.Append("</li>");

        strHouseInfo.Append("<li class=\"wid2c fl\">最后跟进日期： ");
        if (entHouseBaseInfo.ServiceTime != null)
        {
            strHouseInfo.Append(entHouseBaseInfo.ServiceTime.Value.ToString());
        }
        strHouseInfo.Append("</li>");
        
        strHouseInfo.Append("<li class=\"wid2a fl\">所属人："+entHouseBaseInfo.OprPerson+"</li>");
        strHouseInfo.Append("<li class=\"wid2b fl\">所属门店：" + entHouseBaseInfo.OprDepart + "</li>");
        strHouseInfo.Append("<li class=\"wid2a fl\">门店电话：");
        if (string.IsNullOrEmpty(hr_depinfo.Tel))
            strHouseInfo.Append("--");
        else
            strHouseInfo.Append(hr_depinfo.Tel);
        strHouseInfo.Append("</li>");

        strHouseInfo.Append("<li class=\"wid2a fl\">建档人：" + entHouseBaseInfo.AddPerson + "</li>");
        strHouseInfo.Append("<li class=\"wid2b fl\">建档门店：" + entHouseBaseInfo.AddDepart + "</li>");
        strHouseInfo.Append("<li class=\"wid2a fl\"></li>");

        strHouseInfo.Append("<li class=\"wid2c fl\">建档时间： ");
        strHouseInfo.Append(entHouseBaseInfo.Adddate.Value.ToString());
        strHouseInfo.Append("</li>");
        strHouseInfo.Append("</ul>");


        ltHouseInfo.Text = strHouseInfo.ToString();
    }

    private void setViewOwnerInfo(string HouseId)
    {
        //获取查看过房源业主的人的信息

        string strKeyUser = string.Format(Chenxin.Lib.Cache.CacheDataType.HOUSE_VIEWOWNER, HouseId);

        List<Chenxin.Lib.House.Entity.House_ViewOwerInfo> lsViewOwerInfo;

        lsViewOwerInfo = cs.GetList<Chenxin.Lib.House.Entity.House_ViewOwerInfo>(strKeyUser);

        if (!cs.Hit)
        {
            lsViewOwerInfo = Chenxin.Lib.House.BLL.House_BaseInfo.GetViewOwnerInfo(HouseId);
            if (lsViewOwerInfo != null) cs.Set(strKeyUser, lsViewOwerInfo,5);
        }

        Chenxin.Lib.House.Entity.House_ViewOwerInfo entViewOwerInfo;

        StringBuilder strOwerInfo = new StringBuilder();

        if (lsViewOwerInfo != null && lsViewOwerInfo.Count > 0)
        {

            for (int idxCnt = 0; idxCnt < lsViewOwerInfo.Count && idxCnt < 6; idxCnt++)
            {
                entViewOwerInfo = lsViewOwerInfo[idxCnt];

                cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.GLOBAL);
                string ve = string.Format(Chenxin.Lib.Cache.CacheDataType.USER, entViewOwerInfo.ViewEmployeeId);
                Chenxin.Lib.Passport.Entity.Hr_UserInfo entUserInfo;
                entUserInfo = cs.GetObject<Chenxin.Lib.Passport.Entity.Hr_UserInfo>(ve);
                if (!cs.Hit)
                {
                    entUserInfo = Chenxin.Lib.Passport.DAL.Hr_UserInfo.GetEntityById(entViewOwerInfo.ViewEmployeeId);
                    if (entUserInfo != null) cs.Set(ve, entUserInfo);
                }

                strOwerInfo.Append("<tr class=\"tab_line6\">");
                strOwerInfo.Append("<td width=\"37%\">");
                if (entUserInfo == null || string.IsNullOrEmpty(entUserInfo.PicUrlSmall))
                {
                    strOwerInfo.Append("<img src=\"/images/pic_img.gif\" width=\"48\" height=\"48\" />");
                }
                else {
                    strOwerInfo.Append("<img src=\"" + "UploadFile/" + entUserInfo.PicUrlSmall + "\" width=\"48\" height=\"48\" />");
                }
                strOwerInfo.Append("</td>");
                strOwerInfo.Append("<td>");
                strOwerInfo.Append("<p>");
                strOwerInfo.Append(entViewOwerInfo.Employee + "/" + entViewOwerInfo.Depart);
                strOwerInfo.Append("</p>");
                strOwerInfo.AppendFormat("<p>{0:yyyy-MM-dd HH:mm}</p>", entViewOwerInfo.Addtime);
                strOwerInfo.Append("</td>");
                strOwerInfo.Append("</tr>");
            }
        }

        ltOwerInfo.Text = strOwerInfo.ToString();
    }

    private void setHidHouseInfo(Chenxin.Lib.House.Entity.House_BaseInfo entHouseBaseInfo)
    {
        hidAddress.Value = entHouseBaseInfo.Address;
        hidHouseCode.Value = entHouseBaseInfo.HouseCode;
        hidStatus.Value = entHouseBaseInfo.Status.ToString();
        hidCommunity.Value = entHouseBaseInfo.Community;
        hidBuildingName.Value = entHouseBaseInfo.BuildingName;
        hidRoom.Value = entHouseBaseInfo.Room;
        hidIsProtectPhone.Value = entHouseBaseInfo.IsProtectPhone.ToString();
        hidDisplayPhone.Value = entHouseBaseInfo.DisplayPhone;
        hidcbrAddress.Value = entHouseBaseInfo.Community + entHouseBaseInfo.BuildingName + entHouseBaseInfo.Room;
        hidCustomerId.Value = entHouseBaseInfo.CustomerId.ToString();
        hidCityId.Value = entHouseBaseInfo.CityId.ToString();
        hidCompanyId.Value = entHouseBaseInfo.CompanyId.ToString();
        hidPersonId.Value = entHouseBaseInfo.OprPersonId.ToString();
        hidCommunityId.Value = entHouseBaseInfo.CommunityId.ToString();
    }

    private void setHousePic(string houseid)
    {
        string httpPath = System.Configuration.ConfigurationManager.AppSettings["Picture.RootUrl"];
        string fallPath = "";
        List<Chenxin.Lib.House.Entity.House_PicturesInfo> pic_list = Chenxin.Lib.House.DAL.House_PicturesInfo.GetListArray("HouseId='" + houseid + "'");
        string innerHtml = "";
        foreach (Chenxin.Lib.House.Entity.House_PicturesInfo pic in pic_list)
        {
            fallPath = httpPath + pic.ThumbnailUrl;
            innerHtml += "<li><img title='"+pic.PicType+"' src='" + fallPath + "' width='162' height='125' alt='" + pic.PicType + "' /></li>";
        }
        //string innerHtml = "<li><img src='http://static.flickr.com/66/199481236_dc98b5abb3_s.jpg' width='162' height='125' alt='' /></li>" +
        //                "<li><img src='http://static.flickr.com/75/199481072_b4a0d09597_s.jpg' width='162' height='125' alt='' /></li>" +
        //                "<li><img src='http://static.flickr.com/57/199481087_33ae73a8de_s.jpg' width='162' height='125' alt='' /></li>" +
        //                "<li><img src='http://static.flickr.com/77/199481108_4359e6b971_s.jpg' width='162' height='125' alt='' /></li>" +
        //                "<li><img src='http://static.flickr.com/58/199481143_3c148d9dd3_s.jpg' width='162' height='125' alt='' /></li>" +
        //                "<li><img src='http://static.flickr.com/72/199481203_ad4cdcf109_s.jpg' width='162' height='125' alt='' /></li>" +
        //                "<li><img src='http://static.flickr.com/58/199481218_264ce20da0_s.jpg' width='162' height='125' alt='' /></li>" +
        //                "<li><img src='http://static.flickr.com/69/199481255_fdfe885f87_s.jpg' width='162' height='125' alt='' /></li>" +
        //                "<li><img src='http://static.flickr.com/60/199480111_87d4cb3e38_s.jpg' width='162' height='125' alt='' /></li>" +
        //                "<li><img src='http://static.flickr.com/70/229228324_08223b70fa_s.jpg' width='162' height='125' alt='' /></li>";
        //mycarousel.InnerHtml = innerHtml;
        liList.Text = innerHtml;
    }
}
